#include <iostream>
#include <math.h>
using namespace std;


int main(){
	long long n,m,r=0,nn,e,s;
	cin>>n>>m;
	nn = n%2==0?2:1;
	s = n/2.0+0.5;
	e = min(nn*nn,m);
	m = m - e;
	r += e*s;
	nn += 2;
	s--;
	while(m){
		if(s < 0) s=0;
		e = min(nn*nn-((nn-2)*(nn-2)),m);
		m = m - e;
		r += e*s;
		nn += 2;
		s--;
	}
	cout<<r;
}
